#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[200005],mx,n;
void dfs(int i,int lst1,int lst2,int pts){
    if(i==n+1){
        mx=max(mx,pts);
        return;
    }
    dfs(i+1,a[i],lst2,pts+a[i]*(a[i]==lst1));
    dfs(i+1,lst1,a[i],pts+a[i]*(a[i]==lst2));
}
signed main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int T;
    cin>>T;
    while(T--){
        cin>>n;
        for(int i=1;i<=n;i++)
            scanf("%lld",a+i);
        mx=0;
        dfs(1,0,0,0);
        cout<<mx<<"\n";
    }
    return 0;
}
